package Chapter19.homework;

import Chapter19.writer_.FileWriter_;

import java.io.*;

/**
 * @author 杨森
 * @date 2022年11月05日 10:53
 */
public class Homework01 {
    public static void main(String[] args) throws IOException {
        String directoryPath = "e:\\mytemp";
        File file = new File(directoryPath);
        if (!file.exists()) {
            if (file.mkdirs()) {
                System.out.println("创建成功" + directoryPath);
            } else {
                System.out.println("创建失败" + directoryPath);
            }
        }

        String filePath = directoryPath + "\\hello.txt";
        file = new File(filePath);
        if (!file.exists()) {
            if (file.createNewFile()) {
                System.out.println("创建成功" + filePath);

                BufferedWriter br = new BufferedWriter(new FileWriter(file));
                br.write("韩顺平教育");
                br.close();
            } else {
                System.out.println("创建失败" + filePath);
            }
        }else {
            System.out.println(filePath+"已经存在");
        }
    }
}
